<div class="grid-24">
  <?php if (Yii::app()->user->hasFlash('success')): ?>
  <div class="notify notify-success">
    <a href="javascript:;" class="close">×</a>
    <?php echo Yii::app()->user->getFlash('success'); ?>
  </div>
  <?php endif; ?>

  <?php
  $this->renderPartial('_search', array(
      'model' => $searchModel,
      'searchData' => $searchData
  ));
  ?>

  <div class="widget widget-table">
    <div class="widget-header">
      <span class="icon-list"></span>
      <h3 class="icon chart">
        <?php echo Yii::t('main', 'users.list_title'); ?>
      </h3>

    </div>

    <div class="widget-content">
      <div class="dataTables_wrapper">
        <div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
          <div class="dataTables_filter">
            <button class="btn btn-small btn-success" id="btnSettingCommand">
              <span class="icon-plus"></span>
              <?php echo Yii::t('main', 'button.settingcommand'); ?>
            </button>
          </div>
        </div>

        <table class="table table-bordered table-striped">
          <thead>
            <tr>
              <th class="ui-state-default" width="5%"><input type="checkbox" name="checkAll" id="checkAll"
                onclick="usersPage.checkAll()" /></th>
              <th class="ui-state-default" width="15%"><?php echo $sort->extLink('mobile', Yii::t('main', 'users.mobile'), array('class' => 'float_left')); ?>
              </th>
              <th class="ui-state-default" width="20%"><?php echo $sort->extLink('serial_num', Yii::t('main', 'users.serial_num'), array('class' => 'float_left')); ?>
              </th>
              <th class="ui-state-default" width="10%"><?php echo $sort->extLink('network', "Mạng", array('class' => 'float_left')); ?>
              </th>
              <th class="ui-state-default" width="13%"><?php echo $sort->extLink('command', Yii::t('main', 'users.command'), array('class' => 'float_left')); ?>
              </th>
              <th class="ui-state-default" width="10%"><?php echo $sort->extLink('switchboard', Yii::t('main', 'users.switchboard'), array('class' => 'float_left')); ?>
              </th>
              <th class="ui-state-default" width="10%">Trạng thái</th>
              <th class="ui-state-default" width="12%"><?php echo $sort->extLink('create_date', Yii::t('main', 'users.create_date'), array('class' => 'float_left')); ?>
              </th>
              <th class="ui-state-default" width="5%"></th>
            </tr>
          </thead>
          <tbody>
            <?php $i = 1; ?>
            <?php foreach ($models as $model): ?>
            <tr class="gradeA">
              <td><input type="checkbox" class="checkbox" name="selected[]" value="<?php echo $model->user_id; ?>"
                id="user_<?php echo $model->user_id; ?>" onclick="usersPage.select(this)"
  <?php if ($selected && in_array($model->user_id, $selected)): ?> checked="true" <?php endif?> /></td>
              <td><?php echo CHtml::encode($model->mobile); ?>
              </td>
              <td class="center"><?php echo CHtml::encode($model->serial_num); ?>
              </td>
              <td class="center"><?php echo CHtml::encode($model->network); ?>
              </td>
              <td class="center"><?php echo CHtml::encode($model->command); ?>
              </td>
              <td class="center"><?php echo CHtml::encode($model->switchboard); ?>
              </td>
              <td class="text_center">
                <?php if ($model->send_status) : ?>
                  <span style="color: blue;">Đã gửi</span>
                <?php else: ?>
                  <span style="color: red;">Chưa gửi</span>
                <?php endif;?>
              </td>
              <td class="text_center"><?php echo date("Y/m/d", strtotime($model->create_date)); ?>
              </td>
              <td class="text_center">

                <button class="btn btn-small btn-error" type="button"
                  onclick="return usersPage.remove('<?php echo Yii::app()->createUrl('/admin/users/delete', array('id' => $model->user_id)); ?>')">
                  <span class="icon-minus"></span>
                  <?php echo Yii::t('main', 'button.delete'); ?>
                </button>
              </td>
            </tr>
            <?php $i++; ?>
            <?php endforeach; ?>
          </tbody>
        </table>
        <?php $this->renderPartial('../units/_pager', array('pages' => $pages, 'countData' => count($models))); ?>
      </div>
    </div>
    <!-- .widget-content -->
    <input type="hidden" id="selectSize" value="<?php if ($selected) :?> <?php echo sizeof($selected)?><?php else : ?>0<?php endif?>">
  </div>
  <!-- .widget -->

</div>
<div id="dialog" title="Thiết lập" style="display: none;">
<form class="form uniformForm validateForm" id="setting-form" action="/admin/users/setting" method="post">
  <div class="notify notify-error" style="display: none;">
    <a href="javascript:;" class="close">×</a>
    <div id="dialogsms"></div>
  </div>
  <table>
    <tr>
      <td width="30%"><label>Mã lệnh</label>
      </td>
      <td><input type="text" name="command" id="command" size="30">
      </td>
    </tr>
    <tr>
      <td><label>Đầu số DV</label>
      </td>
      <td><input type="text" name="settingswitch" id="settingswitch" size="30">
      </td>
    </tr>
    <tr>
      <td></td>
      <td>
        <button onclick="return usersPage.setting()" class="btn btn-small btn-success" type="submit">
          <span class="icon-check"></span>Đồng ý
        </button>
      </td>
    </tr>
  </table>
  </form>
</div>

<?php
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile(Yii::app()->baseUrl . '/js/users.js');
?>
